// 公共样式文件 - 提取各页面共同的样式模式
// 导入变量文件
@use './variables.scss' as v;

/* ==================== 页面布局样式 ==================== */
// 标准页面容器
.page-container {
	max-width: calc(100vw - 210px); // 默认为展开状态的宽度
	margin: 0 auto;
	padding: 20px;
	height: 100vh;
	overflow: auto;
	transition: max-width 0.3s ease; // 支持动态宽度变化的平滑过渡
}

// 页面头部区域
.page-header {
	text-align: center;
	margin-bottom: 32px;
}

// 页面标题
.page-title {
	font-size: 32px;
	font-weight: 700;
	color: #333;
	margin-bottom: 12px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

// 页面描述
.page-desc {
	font-size: 16px;
	color: #666;
	margin: 0;
	line-height: 1.5;
}

/* ==================== 卡片组件样式 ==================== */
// 基础卡片样式 - 可以应用到任何需要卡片效果的元素
.card-base {
	background: white;
	border-radius: 12px;
	border: 1px solid #f0f0f0;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	transition: all 0.3s ease;

	&.hoverable {
		cursor: pointer;

		&:hover {
			transform: translateY(-2px);
			box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
		}
	}

	// 特殊卡片变体
	&.elevated {
		box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

		&:hover {
			box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
		}
	}
}

/* ==================== 搜索筛选区域样式 ==================== */
// 筛选区域容器
.filter-section {
	@extend .card-base;
	padding: 24px;
	margin-bottom: 24px;
}

// 搜索框容器
.search-box {
	margin-bottom: 16px;

	// 统一搜索输入框样式
	.ant-input-affix-wrapper {
		border-radius: 8px;
		border: 2px solid #f0f0f0;
		transition: all 0.3s ease;

		&:hover {
			border-color: #d9d9d9;
		}

		&:focus-within {
			border-color: #667eea;
			box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
		}
	}
}

// 筛选控件容器
.filter-controls {
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: wrap;
}

/* ==================== 按钮样式 ==================== */
// 主要渐变按钮
.btn-gradient {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border: none;
	border-radius: 8px;
	color: white;
	font-weight: 500;
	transition: all 0.3s ease;

	&:hover {
		background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
		transform: translateY(-1px);
		box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
	}

	&:active {
		transform: translateY(0);
	}

	&:disabled {
		background: #d9d9d9;
		transform: none;
		box-shadow: none;
	}

	// 大尺寸渐变按钮
	&.large {
		height: 48px;
		padding: 0 24px;
		font-size: 16px;
		border-radius: 12px;
	}

	// 圆形按钮
	&.circle {
		border-radius: 50%;
		width: 40px;
		height: 40px;
		padding: 0;
		display: flex;
		align-items: center;
		justify-content: center;
	}
}

// 次要按钮样式
.btn-secondary {
	border: 1px solid #d9d9d9;
	background: white;
	color: #666;
	border-radius: 8px;
	transition: all 0.3s ease;

	&:hover {
		border-color: #667eea;
		color: #667eea;
	}
}

/* ==================== 状态组件样式 ==================== */
// 空状态容器
.empty-state {
	padding: 60px 20px;
	text-align: center;

	.empty-icon {
		font-size: 64px;
		margin-bottom: 16px;
		opacity: 0.6;
	}

	.empty-desc {
		font-size: 14px;
		color: #666;
		margin-bottom: 24px;
		line-height: 1.6;
	}
}

// 加载状态
.loading-state {
	text-align: center;
	padding: 40px 20px;

	.loading-text {
		font-size: 16px;
		color: #666;
		margin-top: 16px;
	}
}

// 骨架屏动画定义
@keyframes skeleton-loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

// 骨架屏混合器 - 供组件内部使用
@mixin skeleton-animation {
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
	border-radius: 8px;
}

// 骨架屏基础类 - 供模板直接使用
.skeleton-base {
	@include skeleton-animation;
}

/* ==================== 网格布局样式 ==================== */
// 响应式网格容器
.grid-container {
	display: grid;
	gap: 20px;

	// 自适应列数的网格
	&.auto-fill {
		grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	}

	&.auto-fit {
		grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	}

	// 固定列数网格
	&.cols-2 {
		grid-template-columns: repeat(2, 1fr);
	}

	&.cols-3 {
		grid-template-columns: repeat(3, 1fr);
	}

	&.cols-4 {
		grid-template-columns: repeat(4, 1fr);
	}
}

/* ==================== 表单样式 ==================== */
// 统一的输入框样式
.form-input {
	border-radius: 8px;
	border: 2px solid #f0f0f0;
	transition: all 0.3s ease;

	&:hover {
		border-color: #d9d9d9;
	}

	&:focus-within {
		border-color: #667eea;
		box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
	}

	:deep(.ant-input) {
		border: none;

		&:focus {
			box-shadow: none;
		}
	}

	// 大尺寸输入框
	&.large {
		.ant-input {
			padding: 0px 16px;
			font-size: 15px;
		}
	}
}

// 表单项间距
.form-item {
	margin-bottom: 20px;

	&.form-item-large {
		margin-bottom: 24px;
	}
}

/* ==================== 列表组件样式 ==================== */
// 列表项基础样式
.list-item {
	display: flex;
	align-items: center;
	padding: 12px 0;
	border-bottom: 1px solid #f0f0f0;
	transition: background-color 0.2s ease;

	&:last-child {
		border-bottom: none;
	}

	&:hover {
		background-color: #fafafa;
	}

	&.clickable {
		cursor: pointer;

		&:hover {
			background-color: #f5f5f5;
		}
	}
}

/* ==================== 标签样式 ==================== */
// 统一的标签样式
.tag-base {
	display: inline-block;
	padding: 4px 8px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 500;
	border: none;

	// 不同颜色的标签
	&.tag-primary {
		background: rgba(102, 126, 234, 0.1);
		color: #667eea;
	}

	&.tag-success {
		background: rgba(82, 196, 26, 0.1);
		color: #52c41a;
	}

	&.tag-warning {
		background: rgba(250, 173, 20, 0.1);
		color: #faad14;
	}

	&.tag-error {
		background: rgba(255, 77, 79, 0.1);
		color: #ff4d4f;
	}
}

/* ==================== 响应式设计 ==================== */
// 移动端适配
@media (max-width: v.$breakpoint-mobile) {
	.page-container {
		padding: 16px;
		// 移动端占满全宽，覆盖桌面端的calc宽度设置
		max-width: 100% !important;
	}

	.page-title {
		font-size: 24px;
	}

	.filter-section {
		padding: 16px;
	}

	.filter-controls {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;

		.ant-select {
			width: 100% !important;
		}
	}

	.grid-container {
		&.auto-fill,
		&.auto-fit {
			grid-template-columns: 1fr;
		}

		&.cols-2,
		&.cols-3,
		&.cols-4 {
			grid-template-columns: 1fr;
		}
	}

	.btn-gradient.large {
		height: 44px;
		font-size: 15px;
	}
}

// 小屏幕适配
@media (max-width: 480px) {
	.page-container {
		padding: 12px;
		// 小屏幕也占满全宽
		max-width: 100% !important;
	}

	.page-title {
		font-size: 20px;
	}

	.filter-section {
		padding: 12px;
	}

	.empty-state {
		padding: 40px 16px;

		.empty-icon {
			font-size: 48px;
		}
	}
}

/* ==================== 工具类 ==================== */
// 常用工具类
.text-center {
	text-align: center;
}
.text-left {
	text-align: left;
}
.text-right {
	text-align: right;
}

.flex {
	display: flex;
}
.flex-center {
	display: flex;
	align-items: center;
	justify-content: center;
}
.flex-between {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.flex-wrap {
	flex-wrap: wrap;
}
.flex-column {
	flex-direction: column;
}

.w-full {
	width: 100%;
}
.h-full {
	height: 100%;
}

.mb-0 {
	margin-bottom: 0;
}
.mb-8 {
	margin-bottom: 8px;
}
.mb-16 {
	margin-bottom: 16px;
}
.mb-24 {
	margin-bottom: 24px;
}
.mb-32 {
	margin-bottom: 32px;
}

.mt-0 {
	margin-top: 0;
}
.mt-8 {
	margin-top: 8px;
}
.mt-16 {
	margin-top: 16px;
}
.mt-24 {
	margin-top: 24px;
}
.mt-32 {
	margin-top: 32px;
}

.p-0 {
	padding: 0;
}
.p-8 {
	padding: 8px;
}
.p-16 {
	padding: 16px;
}
.p-20 {
	padding: 20px;
}
.p-24 {
	padding: 24px;
}

.rounded {
	border-radius: 8px;
}
.rounded-lg {
	border-radius: 12px;
}
.rounded-xl {
	border-radius: 16px;
}
.rounded-full {
	border-radius: 50%;
}

.shadow {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.shadow-lg {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.shadow-xl {
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.cursor-pointer {
	cursor: pointer;
}
.cursor-not-allowed {
	cursor: not-allowed;
}

.overflow-hidden {
	overflow: hidden;
}
.overflow-auto {
	overflow: auto;
}

// 文字溢出处理
.text-ellipsis {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.text-ellipsis-2 {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.text-ellipsis-3 {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
